package com.bw.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bw.domain.SysDictType;
import com.bw.service.SysDictTypeService;
import com.bw.mapper.SysDictTypeMapper;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author 帅气的WY_
* @description 针对表【sys_dict_type(字典类型表)】的数据库操作Service实现
* @createDate 2023-08-15 14:31:07
*/
@Service
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType>
    implements SysDictTypeService{

    @Override
    public Page<SysDictType> getList(Page page, SysDictType dictType) {
        LambdaQueryWrapper<SysDictType> wrapper = new LambdaQueryWrapper<SysDictType>()
                .like(ObjectUtil.isNotEmpty(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName())
                .like(ObjectUtil.isNotEmpty(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType())
                .eq(ObjectUtil.isNotNull(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus())
                .ge(ObjectUtil.isNotNull(dictType.getBeginTime()), SysDictType::getCreateTime, dictType.getBeginTime())
                .le(ObjectUtil.isNotNull(dictType.getEndTime()), SysDictType::getCreateTime, dictType.getEndTime());
        Page<SysDictType> pageList = this.page(page, wrapper);
        return pageList;
    }

    @Override
    public boolean saveDictType(SysDictType dictType) {
        dictType.setCreateTime(new Date());
        dictType.setCreateBy("暂未设置创建人");
        boolean b = this.save(dictType);
        return b;
    }

    @Override
    public boolean updateDictType(SysDictType dictType) {
        dictType.setUpdateTime(new Date());
        dictType.setUpdateBy("暂未设置修改人");
        boolean b = this.updateById(dictType);
        return b;
    }
}




